/*
 * Copyright (c) 2018 - 2019. www.vtuzx.com Inc. All Rights Reserved
 */

package com.vtuzx.kingdee.xqc_core.dao;

import com.vtuzx.core.db.mongo.impl.VtuzxDaoImpl;
import com.vtuzx.core.utils.VtuzxUtil;
import com.vtuzx.kingdee.xqc_core.bean.kingdee.KingdeeAccount;
import com.vtuzx.kingdee.xqc_core.constant.ConfigType;
import org.bson.Document;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.stereotype.Component;

/**
 * 金蝶下推规则DAO
 */
@Component
public class KingdeePushRuleDao extends VtuzxDaoImpl {
    /** 集合名 */
    public static String NAME = "t_kingdee_push_rule";
    /**
     * 构造器
     */
    public KingdeePushRuleDao() {
        super(NAME);
    }

    /**
     * 获取金蝶下推规则
     *
     * @param formId 表单ID
     * @return 下推规则ID
     */
    public String getPushRule(String formId) {
        Document doc = findOne(Criteria.where("formId").is(formId).and("effect").is(true));
        if (doc != null) {
            return VtuzxUtil.getString(doc, "ruleId");
        }
        return "";
    }
}
